Python 3 (ipykernel)
xxxxxxxxxx#!/usr/bin/env python# coding: utf-8import osimport timeimport cv2from osgeo import gdalimport numpy as npfrom matplotlib import pyplot as pltfrom functions1 import * # 匹配点数量阈值N_match1 = 10N_match2 = 6def main(): img_S_path = r'D:\UAV_GE1\Pairs_new4\YX\U2\00061\Ref.jpg' png_folder_path = r'D:\UAV_GE1\Pairs_new4\YX\U2\00061' for filename in os.listdir(png_folder_path): if filename.endswith(".png"): img_U_path = os.path.join(png_folder_path, filename) print(img_U_path) img_S, img_U = read_images(img_S_path, img_U_path) start = time.perf_counter() Max1, Max2, eo1, eo2 = calculate_phase_congruency(img_S, img_U) PFM_1, PFM_2 = compute_PFM(img_S, img_U, eo1, eo2) a1, _ = np.histogram(PFM_1.ravel(), bins=9) a2, _ = np.histogram(PFM_2.ravel(), bins=9) indices = calculate_similarity(a1, a2) print(indices) if match_images(img_S, img_U, PFM_1, PFM_2, Max1, Max2, indices, N_match1, N_match2): print('总耗时 %6.3f' % (time.perf_counter() - start))if __name__ == "__main__": main()D:\UAV_GE1\Pairs_new4\YX\U2\00061\1010.png [5 1 0 6 4 2 7 8 3] 匹配点坐标出错! 匹配点坐标出错! 匹配错误,继续遍历----------------! 匹配正确!
---------------------------------------------------------------------------- 总耗时 37.141 D:\UAV_GE1\Pairs_new4\YX\U2\00061\1020.png [1 6 5 2 0 7 4 8 3] 匹配正确!
---------------------------------------------------------------------------- 总耗时 14.986 D:\UAV_GE1\Pairs_new4\YX\U2\00061\1030.png [6 2 1 7 5 8 3 0 4] 匹配点坐标出错! 匹配点坐标出错! 匹配错误,继续遍历----------------! 匹配正确!
---------------------------------------------------------------------------- 总耗时 37.266 D:\UAV_GE1\Pairs_new4\YX\U2\00061\1040.png [2 7 6 3 1 8 0 4 5] 匹配正确!
---------------------------------------------------------------------------- 总耗时 14.805 D:\UAV_GE1\Pairs_new4\YX\U2\00061\1050.png [7 3 2 8 6 0 4 5 1] 匹配点坐标出错! 匹配点坐标出错! 匹配错误,继续遍历----------------! 匹配正确!
---------------------------------------------------------------------------- 总耗时 37.261 D:\UAV_GE1\Pairs_new4\YX\U2\00061\1060.png [3 8 7 4 2 0 5 1 6] 匹配正确!
---------------------------------------------------------------------------- 总耗时 14.931 D:\UAV_GE1\Pairs_new4\YX\U2\00061\1070.png [8 4 3 0 7 5 1 2 6] 匹配点坐标出错! 匹配点坐标出错! 匹配错误,继续遍历----------------! 匹配正确!
---------------------------------------------------------------------------- 总耗时 37.168 D:\UAV_GE1\Pairs_new4\YX\U2\00061\1080.png [4 0 8 5 3 1 6 2 7] 匹配正确!
---------------------------------------------------------------------------- 总耗时 14.916 D:\UAV_GE1\Pairs_new4\YX\U2\00061\1090.png [0 5 4 1 8 6 2 3 7] 匹配点坐标出错! 匹配错误,继续遍历----------------! 匹配正确!
---------------------------------------------------------------------------- 总耗时 37.044 D:\UAV_GE1\Pairs_new4\YX\U2\00061\1100.png [5 1 0 6 4 2 7 3 8] 匹配正确!
---------------------------------------------------------------------------- 总耗时 14.992 D:\UAV_GE1\Pairs_new4\YX\U2\00061\1110.png [1 6 5 2 0 7 3 4 8] 匹配点坐标出错! 匹配点坐标出错! 匹配错误,继续遍历----------------! 匹配正确!
---------------------------------------------------------------------------- 总耗时 37.911 D:\UAV_GE1\Pairs_new4\YX\U2\00061\1120.png [6 2 1 7 5 3 4 0 8] 匹配正确!
---------------------------------------------------------------------------- 总耗时 16.676 D:\UAV_GE1\Pairs_new4\YX\U2\00061\1130.png [2 7 6 3 1 4 8 5 0] 匹配点坐标出错! 匹配点坐标出错! 匹配错误,继续遍历----------------! 匹配正确!
---------------------------------------------------------------------------- 总耗时 37.836 D:\UAV_GE1\Pairs_new4\YX\U2\00061\1140.png [7 3 2 8 6 4 0 5 1] 匹配正确!
---------------------------------------------------------------------------- 总耗时 15.497 D:\UAV_GE1\Pairs_new4\YX\U2\00061\1150.png [3 8 7 4 2 0 5 1 6] 匹配点坐标出错! 匹配点坐标出错! 匹配错误,继续遍历----------------! 匹配正确!
---------------------------------------------------------------------------- 总耗时 38.461 D:\UAV_GE1\Pairs_new4\YX\U2\00061\1160.png [8 4 3 0 7 5 1 6 2] 匹配正确!
---------------------------------------------------------------------------- 总耗时 15.378 D:\UAV_GE1\Pairs_new4\YX\U2\00061\1170.png [4 0 8 5 3 1 6 7 2] 匹配点坐标出错! 匹配点坐标出错! 匹配错误,继续遍历----------------! 匹配点坐标出错! 匹配错误,继续遍历----------------! 匹配正确!
---------------------------------------------------------------------------- 总耗时 60.014 D:\UAV_GE1\Pairs_new4\YX\U2\00061\1180.png [0 5 4 1 8 6 2 7 3] 匹配正确!
---------------------------------------------------------------------------- 总耗时 14.515 D:\UAV_GE1\Pairs_new4\YX\U2\00061\1190.png [5 1 0 6 4 2 7 8 3] 匹配点坐标出错! 匹配点坐标出错! 匹配错误,继续遍历----------------! 匹配正确!
---------------------------------------------------------------------------- 总耗时 49.333 D:\UAV_GE1\Pairs_new4\YX\U2\00061\1200.png [1 6 5 2 0 7 4 8 3] 匹配正确!
---------------------------------------------------------------------------- 总耗时 14.640 D:\UAV_GE1\Pairs_new4\YX\U2\00061\1210.png [6 2 1 7 5 8 3 0 4] 匹配点坐标出错! 匹配点坐标出错! 匹配错误,继续遍历----------------! 匹配正确!
---------------------------------------------------------------------------- 总耗时 48.748 D:\UAV_GE1\Pairs_new4\YX\U2\00061\1220.png [2 7 6 3 1 8 0 4 5] 匹配点坐标出错! 匹配正确!
---------------------------------------------------------------------------- 总耗时 26.717 D:\UAV_GE1\Pairs_new4\YX\U2\00061\1230.png [7 3 2 8 6 0 4 5 1] 匹配点坐标出错! 匹配点坐标出错! 匹配错误,继续遍历----------------! 匹配点坐标出错! 匹配正确!
---------------------------------------------------------------------------- 总耗时 50.069 D:\UAV_GE1\Pairs_new4\YX\U2\00061\1240.png [3 8 7 4 2 0 5 1 6] 匹配正确!
---------------------------------------------------------------------------- 总耗时 26.335 D:\UAV_GE1\Pairs_new4\YX\U2\00061\1250.png [8 4 3 0 7 5 1 2 6]
--------------------------------------------------------------------------- KeyboardInterrupt Traceback (most recent call last) Cell In[2], line 39 36 print('总耗时 %6.3f' % (time.perf_counter() - start)) 38 if __name__ == "__main__": ---> 39 main() Cell In[2], line 35, in main() 32 indices = calculate_similarity(a1, a2) 33 print(indices) ---> 35 if match_images(img_S, img_U, PFM_1, PFM_2, Max1, Max2, indices, N_match1, N_match2): 36 print('总耗时 %6.3f' % (time.perf_counter() - start)) File functions1.pyx:271, in functions1.match_images() File functions1.pyx:52, in functions1.PC_descriptor_optimized() File <__array_function__ internals>:177, in sum(*args, **kwargs) KeyboardInterrupt:
xxxxxxxxxx